package cn.base.web.file;

import cn.base.web.file.entity.UploadResult;
import cn.rengy.lang.ResultEntity;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;

public interface FileApi {

    /**
     * 后端调用保存文件单个文件
     * @return
     */
    @RequestMapping(value="/file/saveSingle", method = RequestMethod.POST)
    @ResponseBody
    ResultEntity<?,Long> saveSingle(@RequestBody FileSaveEntity fileSaveEntity);

    /**
     * 保存多个文件
     * @return
     */
    @RequestMapping(value="/file/save", method = RequestMethod.POST)
    @ResponseBody
    ResultEntity<?,List<Long>> save(@RequestBody FileSaveEntity fileSaveEntity);


    /**
     * 微服务上传本地文件到admin,客户端上传直接调用admin服务的上传接口
     * 不支持 @RequestPart FileUploadVO fileUploadVO
     * @return
     */
    @RequestMapping(value="/file/uploadAndSave", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    ResultEntity<?,List<UploadResult>> uploadAndSave(@RequestParam Long fileId, @RequestParam Long targetId,@RequestParam(required = false) Long fileItemId, @RequestPart("file") MultipartFile multipartFile) throws Exception;


}
